#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main(){
	printf("start proc:%d, ppid:%d\n",(int)getpid(),(int)getppid());
	//printf("ps");
	//system("ps -ax");
	pid_t pid=fork();
	
	switch(pid){
		case -1:
			printf("error\n");
			exit(0);
		case 0:
			printf("in child proc:%d\n",(int)getpid());
			sleep(500);
			printf("child exit\n");
			break;
		default:
			printf("in parent :%d\n",pid);
			int stat_val;
			pid_t childpid=wait(&stat_val);
			printf("child exit:%d",childpid);
			break;
	}
	//sleep(1);
	exit(0);
}
